import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * @author zhangshuai
 * @version V1.0
 * @Project Java2_26
 * @Package PACKAGE_NAME
 * @Description:
 * @Date 2025/5/15 14:53
 */

public class LinkedListTest {
    public static void main(String[] args) {
        //arrayList 底层是数组。动态的扩容，每次以50%的比例扩容。
        //LinkedList 底层是双向链表。算法
        List<String> linkedList = new LinkedList<>();

        linkedList.add("11");
        linkedList.add("22");
        linkedList.add("33");
        linkedList.add("44");
        linkedList.remove("33");
        System.out.println(linkedList.get(0));
        linkedList.set(0, "55");

        for (String s : linkedList) {
            System.out.println("******"+s);
        }
        for (int i = 0; i < linkedList.size(); i++) {
            System.out.println(linkedList.get(i));
        }
        Iterator<String> iterator = linkedList.iterator();
        while (iterator.hasNext()){
            System.out.println("++++"+iterator.next());
        }
        System.out.println(linkedList);
    }
}